package com.gy.niuer.controller;

import com.gy.niuer.domain.Department;
import com.gy.niuer.service.DepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("/department")
public class DepartmentController {

    @Autowired
    DepartmentService departmentService;

    @GetMapping("/getAll")
    public List<Department> getAllDepartment(){
        List<Department> allDepartment = departmentService.getAllDepartment();
        return allDepartment;
    }

    @GetMapping("/getOne/{id}")
    public Department getOne(@PathVariable int id){
        return departmentService.selectOneById(id);
    }

}
